package dao.impl;

import dao.ClickTrendDao;
import domain.BlackList;
import domain.ClickTrend;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import util.JDBCUtils;

import java.util.List;

public class ClickTrendDaoImpl implements ClickTrendDao {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public List<ClickTrend> SelectAdidCountByHour(String hour) {
        String sql = "SELECT hour,adid,SUM(clickCount) sumclickcount FROM ad_click_trend GROUP BY hour,adid HAVING hour = "+hour+" ORDER BY adid";
        List<ClickTrend> query = template.query(sql, new BeanPropertyRowMapper<ClickTrend>(ClickTrend.class));
        return query;
    }
}
